import { Navigate, useRoutes } from "react-router-dom";
import { RouteObject } from "@/routers/interface";
import Login from "@/views/login/index";
import DataVisualize from "@/views/dataVisualize/index"
import Home from "@/views/home/index";
import Courses from "@/views/courses/idnex";
import Record from "@/views/record"
import LayoutIndex from "@/layouts/index";
import MySetting from '@/views/mySetting'
import Freetime from '@/views/FreeTime'
import Paging from "../reports/weekReport/index";
import DayBody from '../reports/dayReport/showDay';
import AddDayReport from '../reports/dayReport/index'
import AddWeekReport from '../reports/weekReport/Addweek'
import lazyLoad from "@/routers/utils/lazyLoad";
import React from "react";

export const rootRouter: RouteObject[] = [
	{
		path: "/",
		element: <Navigate to="/login" />
	},
	{
		path: "/login",
		element: <Login />,
		meta: {
			title: "登录页",
			key: "login"
		}
	},

	{
		path: "/home",
		element: <LayoutIndex />,
		children: [
			{
				path: "schedule",
				// element: lazyLoad(React.lazy(() => import("@/views/home/index"))),
				meta: {
					title: "个人日程",
					key: "schedule"
				},
				children: [
					{
						path: "free",
						element: <Freetime />,
						meta: {
							title: "我的空闲时间段",
							key: "free"
						}
					},
					{
						path: "record",
						element: <Record />,
						meta: {
							title: "上月打卡记录",
							key: "record"
						}
					},
					{
						path: "courses",
						element: <Courses url='/course/getCourseById' />,
						meta: {
							title: "我的参与课程",
							key: "courses"
						}
					},
					{
						path: "setting",
						element: <MySetting  />,
						meta: {
							title: "我的设置",
							key: "setting"
						}
					},
				]
			},
			{
				path: "weekly",
				
				meta: {
					title: "日志周报",
					key: "weekly"
				},
				children: [
					{
						path: "daily_paper",
						element: <DayBody />,
						meta: {
							title: "我的日报",
							key: "daily_paper"
						},
					},
					{
						path: "addday",
						element: <AddDayReport />,

					},
					{
						path: "addweek",
						element: <AddWeekReport />,

					},
					{
						path: "weekly_paper",
						element: <Paging />,
						meta: {
							title: "我的周报",
							key: "weekly_paper"
						},
					},
					{
						path: "add_week",
						element: <AddDayReport />,
						meta: {
							title: "新增周报",
							key: "add_week"
						},
					}
				]
			},
			{
				path: "share",
			
				meta: {
					title: "分享课表",
					key: "share"
				},
				children: [
					{
						path: "front_sharing",
						element: <Courses url='/course/getCourse' id={0} />,
						meta: {
							title: "前端分享课程",
							key: "front_sharing"
						},
					},
					{
						path: "back_sharing",
						element: <Courses url='/course/getCourse' id={1} />,
						meta: {
							title: "后端分享课程",
							key: "back_sharing"
						},
					},
					{
						path: "test_sharing",
						element: <Courses url='/course/getCourse' id={2} />,
						meta: {
							title: "测试分享课程",
							key: "test_sharing"
						},
					},
					{
						path: "skill_sharing",
						element: <Courses url='/course/getCourse' id={3} />,
						meta: {
							title: "软技能分享课程",
							key: "skill_sharing"
						},
					},
				]
			},
			{
				path: "information",
				element: <DataVisualize />,
				meta: {
					title: "我的统计信息",
					key: "information"
				}
			}
		]
	},
	{
		path: "*",
		element: <Navigate to="/404" />
	},
	{
		path: "/403",
		element: lazyLoad(React.lazy(() => import("@/components/ErrorMessage/403"))),
		meta: {
			
			title: "403页面",
			key: "403"
		}
	},
	{
		path: "/404",
		element: lazyLoad(React.lazy(() => import("@/components/ErrorMessage/404"))),
		meta: {
			
			title: "404页面",
			key: "404"
		}
	},
	{
		path: "/500",
		element: lazyLoad(React.lazy(() => import("@/components/ErrorMessage/500"))),
		meta: {
		
			title: "500页面",
			key: "500"
		}
	},
];

const Router = () => {
	const routes = useRoutes(rootRouter);
	return routes;
};

export default Router;
